package net.zoneland.zrdp.biz.domain.pojo.query;

import lombok.Data;

import net.zoneland.zrdp.biz.common.Constants;
import net.zoneland.zrdp.biz.enums.BusinessprocessEnum;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 任务查询参数类.
 * @author Pbody
 * @since 15:48 2020/9/8
 **/
@Data
public class TaskQuery implements Serializable {

    private static final long serialVersionUID = 5674786169569859169L;

    // 不能为空提示.
    private static final String NOT_BLANK_MESSAGE = "不能为空";

    /** 当前页面. **/
    private Integer pageNum = Constants.PAGER_PAGE;

    /** 每页数据量(thymeleaf分页). **/
    private Integer pageSize = Constants.PAGER_ROWS;

    /** 每页数据量(layui分页). **/
    private Integer limit = Constants.PAGER_LIMIT;

    /** 当前节点编码. **/
    private String sysNodeId;

    /** 包含节点. **/
    @NotNull(message = "包含节点" + NOT_BLANK_MESSAGE)
    private String[] includeNodes;

    /** 流程标题  （流程平台返回的）. **/
    private String applyTitle;

    /** 业务流程名称. **/
    private String[] businessProcesses = StringUtils.split(BusinessprocessEnum.getAllTemplates(), Constants.SPLIT_COMMA);

    /** 会议名称. **/
    private String meetingName;

    /** 工单编号. **/
    @NotBlank(message = "工单编号" + NOT_BLANK_MESSAGE)
    private String piid;

    /** 任务状态. **/
    @NotNull(message = "任务状态" + NOT_BLANK_MESSAGE)
    private int[] states;

    /** 任务所有人. **/
    @NotBlank(message = "任务所有人" + NOT_BLANK_MESSAGE)
    private String owner;

    /** 工单申请人. **/
    private String applicant;

    /** 扩展参数. **/
    private Map<String, String> extendData;
    public void setBusinessProcesses(final List<String> processes){
        businessProcesses = processes.toArray(new String[0]);
    }
}
